#!/usr/bin/env echo "no"
# coding=utf-8

# modify https://github.com/marcomaggi/mbfl

# 0 成功, 1 失败
# __开头的函数是API
# __结尾的函数是私有的
# _格式函数定义 
# 驼峰格式变量定义

if test "$MyBash_LOADED" != 'yes'; 
then
  MyBash_VERSION="0.1.0"

  MyBash_DIR=`cd $(dirname "$BASH_SOURCE"); pwd`

  set +e
	set +m                   # disable monitor mode (job control)
  shopt -s expand_aliases
	shopt -s extglob         # enable extended globbing (required for pattern matching)
	shopt -s extdebug        # enable extended debugging (required for function stack trace)
	hash -r                  # reset hashed command paths
  set +o histexpand        # Bug fix for Bash, parsing exclamation mark.
  
  # Debug mode shows more verbose output to screen and log files.
  # Value: yes or no (y / n)
  DEBUG="no"

  # 库加载 
  __load_module () {
    local module=$1
    local item=$MyBash_DIR/modules/$module
    if test -n "$item" -a -f "$item" -a -r "$item"; 
    then 
      source "$item" &>/dev/null
      if [ $? -ne 0 ]; then
        printf '!!! FATAL: loading module "%s" error\n' "$module" >&2
        return 1
      fi
    fi 
    return 1
  }

  __load_module core.sh

  __require_bash_version 4.0.0

  __load_module base.sh
  __load_module date.sh 
  __load_module string.sh 
  __load_module system.sh

  #__load_module(encode.sh)
  #__load_module(file.sh)
  #__load_module(message.sh)
  #__load_module(log.sh)
  #__load_module(program.sh)
  #__load_module(signal.sh)
  #__load_module(variable.sh)
  #__load_module(dialog.sh)
  #__load_module(net.sh)
  #__load_module(socket.sh)
  #__load_module(http.sh)

  MyBash_LOADED='yes'
fi

